//脚本唯一关键字,通过该关键字找到对应脚本，每个脚本必须有该描述。
/*
脚本说明:
程序员:
*/

var v_script_id = 'authtree_2';
//脚本状态,0:该脚本不许执行，1:该脚本可以执行
var v_status = '1';

//脚本逻辑写在run语句之间
if (run && action.getSession().getAttribute("user").rolekind==2){
	var pid = action.form.getInteger('pid');
	var title = action.form.getString('title');
	var kind = action.form.getInteger('kind');
	var note = action.form.getString('note');
	if(kind ==1){
		var tablename = action.form.getString('tablename');
		var vcol = action.form.getString('vcol');
		var pcol = action.form.getString('pcol');
		var condition = action.form.getString('condition');
	}
	var authtree = action.buildClass('com.handy.plugin.auth.action.AuthTree');
	var ret = authtree.insert(pid, title, kind, note, condition, pcol, vcol, tablename);
	if(ret==0) {
		action.errorCode = 0; 
		action.retString = '添加成功!';//错误文字说明
	}else if(ret==2){
		action.errorCode = 2; 
		action.retString = '添加树结构失败!';//错误文字说明
	}else if(ret==3){
		action.errorCode = 3; 
		action.retString = '动态权限分配失败!请检查填写信息是否正确!';
	}
}